package com.chatmcp.mcprouter.service;

import com.chatmcp.mcprouter.dto.ProxyInfoDto;
import com.chatmcp.mcprouter.dto.ServerConfigDto;
import com.chatmcp.mcprouter.model.SseSession;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

/**
 * Interface for managing SSE sessions
 * This provides comprehensive session lifecycle management
 */
public interface SessionManager {

    /**
     * Create a new session
     *
     * @param key Server key
     * @param serverConfig Server configuration
     * @param proxyInfo Proxy information
     * @return Created session
     */
    SseSession createSession(String key, ServerConfigDto serverConfig, ProxyInfoDto proxyInfo);

    /**
     * Get session by session ID
     *
     * @param sessionId Session ID
     * @return Session or null if not found
     */
    SseSession getSession(String sessionId);

    /**
     * Store session
     *
     * @param sessionId Session ID
     * @param session Session to store
     */
    void storeSession(String sessionId, SseSession session);

    /**
     * Delete session
     *
     * @param sessionId Session ID
     */
    void deleteSession(String sessionId);

    /**
     * Send event to session
     *
     * @param sessionId Session ID
     * @param eventName Event name
     * @param eventData Event data
     * @return True if successful, false otherwise
     */
    boolean sendEvent(String sessionId, String eventName, Object eventData);

    /**
     * Send message to session
     *
     * @param sessionId Session ID
     * @param message Message to send
     * @return True if successful, false otherwise
     */
    boolean sendMessage(String sessionId, String message);

    /**
     * Start heartbeat for session
     *
     * @param sessionId Session ID
     * @param intervalMs Heartbeat interval in milliseconds
     */
    void startHeartbeat(String sessionId, long intervalMs);

    /**
     * Stop heartbeat for session
     *
     * @param sessionId Session ID
     */
    void stopHeartbeat(String sessionId);

    /**
     * Close session
     *
     * @param sessionId Session ID
     */
    void closeSession(String sessionId);
} 